/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.fpt.c0810g.newspj.dataaccess.share;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

/**
 *
 * @author Dao Hai Nam
 */
public class GetConfigInfo {

    public static Map<String, String> getConf(String tagName) {
        Map<String, String> configInfo = new HashMap<String, String>();
        try {
            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
          //  String root = FileSystemView.getFileSystemView().ge.toString();
            Document doc = docBuilder.parse(new File("share/ls-conf/conf.xml"));
            NodeList listConfig = doc.getElementsByTagName("luckyNumber");
            for (int i = 0; i < listConfig.getLength(); i++) {
                if (listConfig.item(i).getNodeName().equals(tagName)) {
                    if (listConfig.item(i).hasChildNodes()) {
                        NodeList list = listConfig.item(i).getChildNodes();
                        for (int j = 0; j < list.getLength(); j++) {
                            configInfo.put(list.item(j).getNodeName(), list.item(j).getNodeValue());
                        }
                    }
                }
            }
        } catch (Exception err) {
            System.out.println(err.toString());
        }
        return configInfo;
    }
}
